package change

import (
	"jlpay-sdk-go/pkg/jlpay/models"
)

// FixedWithdrawModifyRequest 商户定点清算修改请求
type FixedWithdrawModifyRequest struct {
	*models.OrgBaseRequest
	ApplyID          string   `json:"apply_id"`           // 申请单id
	OperateType      string   `json:"operate_type"`       // 设置方式，0-取消1-设置
	WithdrawTimeList []string `json:"withdraw_time_list"` // 定点清算时间列表
}

// NewFixedWithdrawModifyRequest 创建固定提现修改请求实例
func NewFixedWithdrawModifyRequest() *FixedWithdrawModifyRequest {
	return &FixedWithdrawModifyRequest{
		OrgBaseRequest: &models.OrgBaseRequest{},
	}
}

// SetApplyID 设置申请单id
func (r *FixedWithdrawModifyRequest) SetApplyID(applyID string) *FixedWithdrawModifyRequest {
	r.ApplyID = applyID
	return r
}

// SetOperateType 设置设置方式
func (r *FixedWithdrawModifyRequest) SetOperateType(operateType string) *FixedWithdrawModifyRequest {
	r.OperateType = operateType
	return r
}

// SetWithdrawTimeList 设置定点清算时间列表
func (r *FixedWithdrawModifyRequest) SetWithdrawTimeList(withdrawTimeList []string) *FixedWithdrawModifyRequest {
	r.WithdrawTimeList = withdrawTimeList
	return r
}

// ToMap 将请求对象转换为字典
func (r *FixedWithdrawModifyRequest) ToMap() (map[string]interface{}, error) {
	data, err := r.OrgBaseRequest.ToMap()
	if err != nil {
		return nil, err
	}

	data["apply_id"] = r.ApplyID
	data["operate_type"] = r.OperateType
	data["withdraw_time_list"] = r.WithdrawTimeList

	return data, nil
}

// FixedWithdrawModifyResponse 商户定点清算修改响应参数
type FixedWithdrawModifyResponse struct {
	*models.StandardResponse
	MerchNo string `json:"merch_no"` // 商户号
	ApplyID string `json:"apply_id"` // 业务申请编号
}

// NewFixedWithdrawModifyResponse 创建固定提现修改响应实例
func NewFixedWithdrawModifyResponse() *FixedWithdrawModifyResponse {
	return &FixedWithdrawModifyResponse{
		StandardResponse: &models.StandardResponse{},
	}
}

// ToMap 将响应对象转换为字典
func (r *FixedWithdrawModifyResponse) ToMap() (map[string]interface{}, error) {
	data := make(map[string]interface{})

	// 添加基础响应字段
	if r.RetCode != "" {
		data["ret_code"] = r.RetCode
	}
	if r.RetMsg != "" {
		data["ret_msg"] = r.RetMsg
	}

	// 添加业务字段
	if r.MerchNo != "" {
		data["merch_no"] = r.MerchNo
	}
	if r.ApplyID != "" {
		data["apply_id"] = r.ApplyID
	}

	return data, nil
}
